

import java.awt.*;
import java.awt.event.*;

public class DrawingCanvasListener 
     implements MouseListener, MouseMotionListener, KeyListener{

  protected DrawingCanvas canvas;
  protected Point startingMousePosition;
//  public MultiDraw2 md;

  /* Constructor */
  public DrawingCanvasListener(DrawingCanvas canvas) {
    this.canvas=canvas;
  }

  	  public void mousePressed(MouseEvent e) {
  		  if(canvas.md.userName.equals(canvas.md.ownerOfControl)){
		    Tool tool = (canvas).getCurrentTool();
		    if (tool != null) {
		      tool.mousePressed(e);
		    }
  		  }
	  }

	  public void mouseReleased(MouseEvent e) { 
		  if(canvas.md.userName.equals(canvas.md.ownerOfControl)){
		    Tool tool = (canvas).getCurrentTool();
		    if(tool != null) {
		      tool.mouseReleased(e);
		    }
		  }
	  }

	  public void mouseDragged(MouseEvent e) {
		  if(canvas.md.userName.equals(canvas.md.ownerOfControl)){
		    Tool tool =(canvas).getCurrentTool();
		    if(tool != null) {
		      tool.mouseDragged(e);
		    }
		  }
	  }
  public void mouseClicked(MouseEvent e) {}
  public void mouseEntered(MouseEvent e) {}
  public void mouseExited(MouseEvent e) {}
  public void mouseMoved(MouseEvent e) {}

  public void keyTyped(KeyEvent e) {}
  public void keyReleased(KeyEvent e) {}
  
  public void keyPressed(KeyEvent e) {
	 
	    Tool tool =(canvas).getCurrentTool();
	    if(tool != null) {
	      tool.keyPressed(e);
	    }
  }
  




} /* end of class DrawingCanvasListener */
